<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>${requestScope.data.cagetory.name}</title>
</head>
<body>
<link href="${pageContext.request.contextPath}/resources/shop/css/article.css" rel="stylesheet" type="text/css"/>
<link href="${pageContext.request.contextPath}/resources/shop/css/pagnination.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/shop/js/pagination.js"></script>
<div class="container articleList">
    <div class="span6">
        <div class="hotArticleCategory">
            <div class="title">热点分类</div>
            <c:forEach var="item" items="${requestScope.data.categories}" varStatus="index">
            <c:choose>
            <c:when test="${index.index==fn:length(requestScope.data.categories)-1}">
            <dl class="last">
                </c:when>
                <c:otherwise>
                <dl>
                    </c:otherwise>
                    </c:choose>
                    <dt>
                        <a href="${pageContext.request.contextPath}/article/list.html?id=${item.id}">${item.name}</a>
                    </dt>
                </dl>
                </c:forEach>
        </div>
        <div class="hotArticle">
            <div class="title">热点文章</div>
            <ul>
                <c:forEach items="${requestScope.data.hotArticles}" var="item">
                    <li>
                        <a href="${pageContext.request.contextPath}/article/content.html?id=${item.id}"
                           title="${item.title}">
                            <div style="width: 215px;overflow:  hidden; white-space: nowrap; -o-text-overflow: ellipsis; text-overflow:  ellipsis;">${item.title}</div>
                        </a>
                    </li>
                </c:forEach>
            </ul>
        </div>
    </div>
    <div class="span18 last">
        <div class="path">
            <ul>
                <li>
                    <a href="${pageContext.request.contextPath}">首页</a>
                </li>
                <li class="last">${requestScope.data.cagetory.name}</li>
            </ul>
        </div>

        <div class="result">
            <c:choose>
                <c:when test="${fn:length(requestScope.data.paginationMap.data)>0}">
                    <ul>
                        <c:forEach var="item" items="${requestScope.data.paginationMap.data}" varStatus="index">
                            <c:choose>
                                <c:when test="${index.index+1>=fn:length(requestScope.data.paginationMap.data)}">
                                    <li class="last">
                                </c:when>
                                <c:otherwise>
                                    <li>
                                </c:otherwise>
                            </c:choose>
                            <a href="${pageContext.request.contextPath}/article/content.html?id=${item.id}"
                               title="${item.title}">${item.title}</a>
                        <span title="${item.createDate}"><fmt:formatDate pattern="yyyy-MM-dd"
                                                                         value="${item.createDate}"/></span>

                            <p>${item.contentText}</p>
                            </li>
                        </c:forEach>
                    </ul>
                </c:when>
                <c:otherwise>
                    <dl>
                        <dt>对不起，没有找到相关文章</dt>
                        <dd>可尝试浏览其它文章分类</dd>
                    </dl>
                </c:otherwise>
            </c:choose>

        </div>
        <c:if test="${requestScope.data.paginationMap.pageNum>1}">
            <div id="kkpager" style="text-align: right"></div>
            <script type="text/javascript">
                kkpager.generPageHtml({
                    pno: '${requestScope.data.paginationMap.pageNow}',
                    mode: 'link', //可选，默认就是link
                    //总页码
                    total: '${requestScope.data.paginationMap.pageNum}',
                    //总数据条数
                    totalRecords: '${requestScope.data.paginationMap.dataNum}',
                    //链接前部
                    hrefFormer: '${pageContext.request.contextPath}/article/list.html?id=${requestScope.data.cagetory.id}&pageNow=',
                    //链接算法
                    getLink: function (n) {
                        return this.hrefFormer + n;
                    },
                    isShowTotalPage: true,
                    isShowTotalRecords: false,
                    isGoPage: false
                });
            </script>
        </c:if>
    </div>
</div>
</body>
</html>